package com.yaoli.ZuoChengYun;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by YaoLi on 2017/9/1.
 */
public class Main {
    public static void main(String[] args) {
        Scanner ninput = new Scanner(System.in);
        int n = ninput.nextInt();
        List<String> list = new ArrayList<>();

        ninput.nextLine();

        for (int i = 0; i < n; i++) {
            String temp = ninput.nextLine();
            list.add(temp);
        }

        for(int i = 0 ; i < list.size() ; i++){
            String [] lines = list.get(i).split(" ");
            for(int j = lines.length - 1 ; j >= 0 ; j--){
                if(j == 0){
                    System.out.print(lines[j]);
                }else{
                    System.out.print(lines[j]+" ");
                }
            }
            System.out.println();
        }

    }
}
